
<!DOCTYPE html
  PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml">
   <head>
      <meta charset="utf-8"></meta>
      <meta name="viewport" content="width=device-width, initial-scale=1.0"></meta>
      <title>7.10.&nbsp;GraphML Import / Export - Chapter&nbsp;7.&nbsp;Export / Import</title>
      <link rel="stylesheet" type="text/css" href="../../docbook.css"></link>
      <link rel="stylesheet" type="text/css" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"></link>
      <link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.13/css/jquery.dataTables.min.css"></link>
      <link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.1.0/css/font-awesome.min.css"></link>
      <link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Open+Sans:400,300,400italic,600,300italic"></link>
      <link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/codemirror/5.11.0/codemirror.min.css"></link>
      <link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/codemirror/5.11.0/theme/neo.min.css"></link>
      <link rel="stylesheet" type="text/css" href="../../css/chunked-base.css"></link>
      <link rel="stylesheet" type="text/css" href="../../css/extra.css"></link><script src="//code.jquery.com/jquery-1.12.4.js" type="text/javascript"></script><script src="//cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js" type="text/javascript"></script><script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" type="text/javascript"></script><script src="//cdnjs.cloudflare.com/ajax/libs/codemirror/5.11.0/codemirror.min.js" type="text/javascript"></script><script src="//cdnjs.cloudflare.com/ajax/libs/codemirror/5.11.0/addon/runmode/runmode.min.js" type="text/javascript"></script><script src="//cdnjs.cloudflare.com/ajax/libs/codemirror/5.11.0/mode/cypher/cypher.min.js" type="text/javascript"></script><script src="../../javascript/datatable.js" type="text/javascript"></script><script src="../../javascript/colorize.js" type="text/javascript"></script><script src="../../javascript/tabs-for-chunked.js" type="text/javascript"></script><script src="../../javascript/mp-nav.js" type="text/javascript"></script><script src="../../javascript/versionswitcher.js" type="text/javascript"></script><script src="../../javascript/version.js" type="text/javascript"></script><script src="//s3-eu-west-1.amazonaws.com/alpha.neohq.net/docs/new-manual/assets/search.js" type="text/javascript"></script><meta name="generator" content="DocBook XSL Stylesheets V1.79.1"></meta>
      <link rel="prev" href="../gephi/" title="7.6.11.&nbsp;Streaming Data to Gephi"></link>
      <link rel="next" href="../../database-integration/" title="Chapter&nbsp;8.&nbsp;Database Integration"></link>
      <link rel="shortcut icon" href="https://neo4j.com/wp-content/themes/neo4jweb/favicon.ico"></link><script>
        $(document).ready(function() {
          CodeMirror.colorize();
          tabTheSource($('body'));
          var $header = $('header').first();
          $header.prepend(
            $('<a href="" id="logo"><img src="https://neo4j.com/wp-content/themes/neo4jweb/assets/images/neo4j-logo-2015.png" alt="Neo4j Logo"></img></a>')
          );
          var $sidebar = $('<div id="sidebar-wrapper"></div>');
          $.get('toc.html', function (d){
            $(d).appendTo($sidebar);
            highlightToc();
            highlightLibraryHeader();
          });
          $sidebar.insertAfter($('header').first());
        });
        </script></head>
   <body>
      <header>
         <div class="searchbox">
            <form id="search-form" class="search" name="search-form" role="search"><input id="search-form-input" name="q" title="search" type="search" lang="en" placeholder="Search Neo4j docs..." aria-label="Search Neo4j documentation" max-length="128" required="required"></input><input id="search-form-button" type="submit" value="Search"></input></form>
         </div>
         <ul class="documentation-library">
            <li><a href="https://neo4j.com/docs/operations-manual/current">Operations Manual</a></li>
            <li><a href="https://neo4j.com/docs/developer-manual/current/">Developer Manual</a></li>
            <li><a href="https://neo4j.com/docs/ogm-manual/current/">OGM Manual</a></li>
            <li><a href="https://neo4j.com/docs/graph-algorithms/current/">Graph Algorithms</a></li>
            <li><a href="https://neo4j-contrib.github.io/neo4j-apoc-procedures/3.4/">APOC</a></li>
            <li><a href="https://neo4j.com/docs/java-reference/current/">Java Reference</a></li>
         </ul>
         <nav id="header-nav"><span class="nav-previous"><a accesskey="p" href="../gephi/"><span class="fa fa-long-arrow-left" aria-hidden="true"></span>Streaming Data to Gephi</a></span><span class="nav-current">
               <p class="nav-title hidden">7.10.&nbsp;GraphML Import / Export</p></span><span class="nav-next"><a accesskey="n" href="../../database-integration/">Database Integration<span class="fa fa-long-arrow-right" aria-hidden="true"></span></a></span></nav>
      </header>
      <div id="search-results" class="hidden"></div>
      <section class="section" id="graphml">
         <div class="titlepage">
            <div>
               <div>
                  <h2 class="title" style="clear: both"><a class="anchor" href="#graphml"></a>7.10.&nbsp;GraphML Import / Export
                  </h2>
               </div>
            </div>
         </div>
         <p>GraphML is used by other tools, like Gephi and CytoScape to read graph data.</p>
         <p><code class="literal">YIELD file, source, format, nodes, relationships, properties, time</code></p>
         <div class="informaltable">
            <div class="table" id="d0e8528">
               <table class="informaltable" border="1">
                  <colgroup>
                     <col class="col_1"></col>
                     <col class="col_2"></col>
                  </colgroup>
                  <tbody>
                     <tr>
                        <td style="text-align: left; vertical-align: top; ">
                           <p><code class="literal">apoc.import.graphml(file-or-url,{batchSize: 10000, readLabels: true, storeNodeIds: false, defaultRelationshipType:"RELATED"})</code></p>
                        </td>
                        <td style="text-align: left; vertical-align: top; ">
                           <p>imports graphml into the graph</p>
                        </td>
                     </tr>
                     <tr>
                        <td style="text-align: left; vertical-align: top; ">
                           <p><code class="literal">apoc.export.graphml.all(file,config)</code></p>
                        </td>
                        <td style="text-align: left; vertical-align: top; ">
                           <p>exports whole database as graphml to the provided file</p>
                        </td>
                     </tr>
                     <tr>
                        <td style="text-align: left; vertical-align: top; ">
                           <p><code class="literal">apoc.export.graphml.data(nodes,rels,file,config)</code></p>
                        </td>
                        <td style="text-align: left; vertical-align: top; ">
                           <p>exports given nodes and relationships as graphml to the provided file</p>
                        </td>
                     </tr>
                     <tr>
                        <td style="text-align: left; vertical-align: top; ">
                           <p><code class="literal">apoc.export.graphml.graph(graph,file,config)</code></p>
                        </td>
                        <td style="text-align: left; vertical-align: top; ">
                           <p>exports given graph object as graphml to the provided file</p>
                        </td>
                     </tr>
                     <tr>
                        <td style="text-align: left; vertical-align: top; ">
                           <p><code class="literal">apoc.export.graphml.query(query,file,config)</code></p>
                        </td>
                        <td style="text-align: left; vertical-align: top; ">
                           <p>exports nodes and relationships from the Cypher statement as graphml to the provided file</p>
                        </td>
                     </tr>
                  </tbody>
               </table>
            </div>
         </div>
         <p>All <code class="literal">Point</code> or <code class="literal">Temporal</code> data types are exported formatted as a String
         </p>
         <p>e.g:</p>
         <div class="informaltable">
            <div class="table" id="d0e8583">
               <table class="informaltable" border="1">
                  <colgroup>
                     <col class="col_1"></col>
                     <col class="col_2"></col>
                  </colgroup>
                  <tbody>
                     <tr>
                        <td style="text-align: left; vertical-align: top; ">
                           <p><code class="literal">Point 3d</code></p>
                        </td>
                        <td style="text-align: left; vertical-align: top; ">
                           <p>{"crs":"wgs-84-3d","latitude":56.7,"longitude":12.78,"height":100.0}</p>
                        </td>
                     </tr>
                     <tr>
                        <td style="text-align: left; vertical-align: top; ">
                           <p><code class="literal">Point 2d</code></p>
                        </td>
                        <td style="text-align: left; vertical-align: top; ">
                           <p>{"crs":"wgs-84-3d","latitude":56.7,"longitude":12.78,"height":null}</p>
                        </td>
                     </tr>
                     <tr>
                        <td style="text-align: left; vertical-align: top; ">
                           <p><code class="literal">Date</code></p>
                        </td>
                        <td style="text-align: left; vertical-align: top; ">
                           <p>2018-10-10</p>
                        </td>
                     </tr>
                     <tr>
                        <td style="text-align: left; vertical-align: top; ">
                           <p><code class="literal">LocalDateTime</code></p>
                        </td>
                        <td style="text-align: left; vertical-align: top; ">
                           <p>2018-10-10T00:00</p>
                        </td>
                     </tr>
                  </tbody>
               </table>
            </div>
         </div>
         <div class="table" id="d0e8620">
            <table class="table" summary="configuration options" border="1">
               <caption class="table-title">Table&nbsp;7.4.&nbsp;configuration options</caption>
               <colgroup>
                  <col class="col_1"></col>
                  <col class="col_2"></col>
                  <col class="col_3"></col>
               </colgroup>
               <thead>
                  <tr>
                     <th style="text-align: left; vertical-align: top; ">param</th>
                     <th style="text-align: left; vertical-align: top; ">default</th>
                     <th style="text-align: left; vertical-align: top; ">description</th>
                  </tr>
               </thead>
               <tbody>
                  <tr>
                     <td style="text-align: left; vertical-align: top; ">
                        <p>format</p>
                     </td>
                     <td style="text-align: left; vertical-align: top; ">&nbsp;</td>
                     <td style="text-align: left; vertical-align: top; ">
                        <p>In export to Graphml script define the export format. Possible value is: "gephi"</p>
                     </td>
                  </tr>
                  <tr>
                     <td style="text-align: left; vertical-align: top; ">
                        <p>caption</p>
                     </td>
                     <td style="text-align: left; vertical-align: top; ">&nbsp;</td>
                     <td style="text-align: left; vertical-align: top; ">
                        <p>It&#8217;s an array of string (i.e. ['name','title']) that define an ordered set of properties eligible as value for the <code class="literal">Label</code> value, if no match is found the there is a fallback to the node label, if the node label is missing the then the ID is used
                        </p>
                     </td>
                  </tr>
                  <tr>
                     <td style="text-align: left; vertical-align: top; ">
                        <p>useTypes</p>
                     </td>
                     <td style="text-align: left; vertical-align: top; ">
                        <p>false</p>
                     </td>
                     <td style="text-align: left; vertical-align: top; ">
                        <p>Write the attribute type information to the graphml output</p>
                     </td>
                  </tr>
               </tbody>
            </table>
         </div>
         <section class="section" id="_note_3">
            <div class="titlepage">
               <div>
                  <div>
                     <h3 class="title"><a class="anchor" href="#_note_3"></a>7.10.1.&nbsp;Note:
                     </h3>
                  </div>
               </div>
            </div>
            <p>The labels exported are ordered alphabetically.
               The output of <code class="literal">labels()</code> function is not sorted, use it in combination with <code class="literal">apoc.coll.sort()</code>.
            </p>
            <div class="table" id="d0e8676">
               <table class="table" summary="configuration options" border="1">
                  <caption class="table-title">Table&nbsp;7.5.&nbsp;configuration options</caption>
                  <colgroup>
                     <col class="col_1"></col>
                     <col class="col_2"></col>
                     <col class="col_3"></col>
                  </colgroup>
                  <thead>
                     <tr>
                        <th style="text-align: left; vertical-align: top; ">param</th>
                        <th style="text-align: left; vertical-align: top; ">default</th>
                        <th style="text-align: left; vertical-align: top; ">description</th>
                     </tr>
                  </thead>
                  <tbody>
                     <tr>
                        <td style="text-align: left; vertical-align: top; ">
                           <p>batchSize</p>
                        </td>
                        <td style="text-align: left; vertical-align: top; ">
                           <p>20000</p>
                        </td>
                        <td style="text-align: left; vertical-align: top; ">
                           <p>define the batch size</p>
                        </td>
                     </tr>
                     <tr>
                        <td style="text-align: left; vertical-align: top; ">
                           <p>delim</p>
                        </td>
                        <td style="text-align: left; vertical-align: top; ">
                           <p>","</p>
                        </td>
                        <td style="text-align: left; vertical-align: top; ">
                           <p>define the delimiter character (export csv)</p>
                        </td>
                     </tr>
                     <tr>
                        <td style="text-align: left; vertical-align: top; ">
                           <p>arrayDelim</p>
                        </td>
                        <td style="text-align: left; vertical-align: top; ">
                           <p>";"</p>
                        </td>
                        <td style="text-align: left; vertical-align: top; ">
                           <p>define the delimiter character for arrays (used in the bulk import)</p>
                        </td>
                     </tr>
                     <tr>
                        <td style="text-align: left; vertical-align: top; ">
                           <p>quotes</p>
                        </td>
                        <td style="text-align: left; vertical-align: top; ">
                           <p>'always'</p>
                        </td>
                        <td style="text-align: left; vertical-align: top; ">
                           <p>quote-character used for CSV, possible values are: 'always', 'none', 'ifNeeded'</p>
                        </td>
                     </tr>
                     <tr>
                        <td style="text-align: left; vertical-align: top; ">
                           <p>useTypes</p>
                        </td>
                        <td style="text-align: left; vertical-align: top; ">
                           <p>false</p>
                        </td>
                        <td style="text-align: left; vertical-align: top; ">
                           <p>add type on file header (export csv and graphml export)</p>
                        </td>
                     </tr>
                     <tr>
                        <td style="text-align: left; vertical-align: top; ">
                           <p>format</p>
                        </td>
                        <td style="text-align: left; vertical-align: top; ">
                           <p>"neo4j-shell"</p>
                        </td>
                        <td style="text-align: left; vertical-align: top; ">
                           <p>In export to Cypher script define the export format. Possible values are: "cypher-shell","neo4j-shell" and "plain"</p>
                        </td>
                     </tr>
                     <tr>
                        <td style="text-align: left; vertical-align: top; ">
                           <p>nodesOfRelationships</p>
                        </td>
                        <td style="text-align: left; vertical-align: top; ">
                           <p>false</p>
                        </td>
                        <td style="text-align: left; vertical-align: top; ">
                           <p>if enabled add relationship between nodes (export Cypher)</p>
                        </td>
                     </tr>
                     <tr>
                        <td style="text-align: left; vertical-align: top; ">
                           <p>storeNodeIds</p>
                        </td>
                        <td style="text-align: left; vertical-align: top; ">
                           <p>false</p>
                        </td>
                        <td style="text-align: left; vertical-align: top; ">
                           <p>set nodes' ids (import/export graphml)</p>
                        </td>
                     </tr>
                     <tr>
                        <td style="text-align: left; vertical-align: top; ">
                           <p>readLabels</p>
                        </td>
                        <td style="text-align: left; vertical-align: top; ">
                           <p>false</p>
                        </td>
                        <td style="text-align: left; vertical-align: top; ">
                           <p>read nodes' labels (import/export graphml)</p>
                        </td>
                     </tr>
                     <tr>
                        <td style="text-align: left; vertical-align: top; ">
                           <p>defaultRelationshipType</p>
                        </td>
                        <td style="text-align: left; vertical-align: top; ">
                           <p>"RELATED"</p>
                        </td>
                        <td style="text-align: left; vertical-align: top; ">
                           <p>set relationship type (import/export graphml)</p>
                        </td>
                     </tr>
                     <tr>
                        <td style="text-align: left; vertical-align: top; ">
                           <p>separateFiles</p>
                        </td>
                        <td style="text-align: left; vertical-align: top; ">
                           <p>false</p>
                        </td>
                        <td style="text-align: left; vertical-align: top; ">
                           <p>export results in separated file by type (nodes, relationships..)</p>
                        </td>
                     </tr>
                     <tr>
                        <td style="text-align: left; vertical-align: top; ">
                           <p>cypherFormat</p>
                        </td>
                        <td style="text-align: left; vertical-align: top; ">
                           <p>create</p>
                        </td>
                        <td style="text-align: left; vertical-align: top; ">
                           <p>In export to cypher script, define the cypher format (for example use <code class="literal">MERGE</code> instead of <code class="literal">CREATE</code>). Possible values are: "create", "updateAll", "addStructure", "updateStructure".
                           </p>
                        </td>
                     </tr>
                     <tr>
                        <td style="text-align: left; vertical-align: top; ">
                           <p>bulkImport</p>
                        </td>
                        <td style="text-align: left; vertical-align: top; ">
                           <p>true</p>
                        </td>
                        <td style="text-align: left; vertical-align: top; ">
                           <p>In export it creates files for Neo4j Admin import</p>
                        </td>
                     </tr>
                     <tr>
                        <td style="text-align: left; vertical-align: top; ">
                           <p>separateHeader</p>
                        </td>
                        <td style="text-align: left; vertical-align: top; ">
                           <p>false</p>
                        </td>
                        <td style="text-align: left; vertical-align: top; ">
                           <p>In export it creates two file one for header and one for data</p>
                        </td>
                     </tr>
                  </tbody>
               </table>
            </div>
            <p>Values for the <code class="literal">quotes</code> configuration:
               * <code class="literal">none</code>: the same behaviour of the current <code class="literal">false</code>
               * <code class="literal">always</code>:  the same behaviour of the current <code class="literal">true</code>
               * <code class="literal">ifNeeded</code>: it applies quotes only when it&#8217;s necessary;
            </p>
            <p>When the config <code class="literal">bulkImport</code> is enable it create a list of file that can be used for Neo4j Bulk Import.
            </p>
            <p><span class="strong"><strong>This config can be used only with <code class="literal">apoc.export.csv.all</code> and <code class="literal">apoc.export.csv.graph</code></strong></span></p>
            <p>All file create are named as follow:</p>
            <div class="itemizedlist">
               <ul class="itemizedlist" style="list-style-type: disc; ">
                  <li class="listitem">Nodes file are construct with the name of the input file append with <code class="literal">.nodes.[LABEL_NAME].csv</code></li>
                  <li class="listitem">Rel file are construct with the name of the input file append with <code class="literal">.relationships.[TYPE_NAME].csv</code></li>
               </ul>
            </div>
            <p>If Node or Relationship have more than one Label/Type it will create one file for Label/Type.</p>
         </section>
      </section>
      <footer><script type="text/javascript">
          (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
            (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
          m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
          })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
          //Allow Linker
          ga('create', 'UA-1192232-34','auto', {'allowLinker': true});
          ga('send', 'pageview');
          // Load the plugin.
          ga('require', 'linker');
          // Define which domains to autoLink.
          ga('linker:autoLink', ['neo4j.org','neo4j.com','neotechnology.com','graphdatabases.com','graphconnect.com']);
        </script><script type="text/javascript">
          document.write(unescape("%3Cscript src='//munchkin.marketo.net/munchkin.js' type='text/javascript'%3E%3C/script%3E"));
        </script><script>Munchkin.init('773-GON-065');</script></footer>
   </body>
</html>